home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / util / libs / prooflibrary10.lha / prooflibrary / examples / owner / main.c next >
C/C++ Source or Header  |  1999-01-30  |  2KB  |  99 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. #include <exec/execbase.h>
  5. #include <exec/memory.h>
  6. #include <exec/types.h>
  7. #include <intuition/intuition.h>
  8. #include <intuition/intuitionbase.h>
  9.  
  10. #include <proof/proof.h>
  11. #include <proof/proof_protos.h>
  12. #include <proof/proof_pragmas.h>
  13.  
  14. #include <clib/exec_protos.h>
  15. #include <clib/dos_protos.h>
  16. #include <clib/intuition_protos.h>
  17.  
  18. #include <pragmas/exec_pragmas.h>
  19. #include <pragmas/dos_pragmas.h>
  20. #include <pragmas/intuition_pragmas.h>
  21.  
  22. /* Function prototypes */
  23.  
  24. /* Global variables */
  25. extern struct Library *DOSBase;
  26. struct Library *ProofBase;
  27.  
  28. char *version = "$VER: ProofOwner 1.0 (19.9.99)";
  29.  
  30. void main( int argc, char **argv )
  31. {
  32.     ULONG err;
  33.     char *str;
  34.     UBYTE att;
  35.  
  36.     ProofBase = OpenLibrary( "proof.library", NULL );
  37.     if ( ProofBase != NULL )
  38.     {
  39.         struct ProofOwner *po = NULL;
  40.  
  41.         err = AllocProofOwner( &po, NULL );
  42.         if ( err == PFERR_NONE )
  43.         {
  44.             int i;
  45.             char tempstr[20];
  46.  
  47.             SetProofOwnerAttrs( po,
  48.                 PFN_ProofOwnerID, 50,
  49.                 PFN_ProofOwnerIdent, "Test user",
  50.                 TAG_DONE );
  51.  
  52.             for ( i = 0; i <=3; i++ )
  53.             {
  54.                 sprintf( tempstr, "group %d", i );
  55.                 SetProofOwnerEntry( po, i, POWN_GROUP_NAME, tempstr );
  56.             }
  57.  
  58.             SetProofOwnerEntry( po, 0, 2, "group 0 cat 2" );
  59.  
  60.             for ( i = 0; i <=3; i++ )
  61.             {
  62.                 str = GetProofOwnerEntry( po, i, POWN_GROUP_NAME );
  63.                 if ( str ) printf("GET:%s\n",str);
  64.             }
  65.  
  66.             err = SaveProofOwner( po, PFN_ProofOwnerName, "ram:test", TAG_DONE );
  67.             if ( err != NULL ) printf("save error:%d\n",err);
  68.  
  69.             FreeProofOwner( &po, NULL );
  70.  
  71.  
  72.             po = NULL;
  73.  
  74.             err = LoadProofOwner( "ram:test", &po, NULL );
  75.             if ( err == PFERR_NONE )
  76.             {
  77.                 GetProofOwnerAttrs( po, PFN_ProofOwnerID, &att, TAG_DONE );
  78.                 printf("OWNER ID=%d\n", att );
  79.                 GetProofOwnerAttrs( po, PFN_ProofOwnerIdent, &str, TAG_DONE );
  80.                 printf("OWNER=%s\n", str );
  81.  
  82.                 for ( i = 0; i <=3; i++ )
  83.                 {
  84.                     str = GetProofOwnerEntry( po, i, POWN_GROUP_NAME );
  85.                     if ( str ) printf("GET:%s\n",str);
  86.                 }
  87.  
  88.                 printf("%s\n", GetProofOwnerEntry( po, 0, 2 ) );
  89.  
  90.                 FreeProofOwner( &po, NULL );
  91.             }
  92.             else printf("load error:%d\n",err);        
  93.         }
  94.         else printf("allocate error:%d\n",err);
  95.     }
  96.  
  97.     if ( ProofBase != NULL ) CloseLibrary( ProofBase );
  98. }
  99.